package com.eshop.modules.product.service.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;
import com.eshop.modules.product.vo.StoreProductReplyQueryVo;
import org.springframework.stereotype.Repository;
import com.eshop.modules.product.domain.StoreProductReply;
import com.eshop.common.mapper.CoreMapper;

@Repository
public interface StoreProductReplyMapper extends CoreMapper<StoreProductReply>
{
    @Select({ "select A.product_score as productScore,A.service_score as serviceScore,A.comment,A.merchant_reply_content as merchantReplyContent,A.merchant_reply_time as merchantReplyTime,A.pics as pictures,A.create_Time as createTime,B.nickname,B.avatar,C.cart_info as cartInfo from store_product_reply A left join eshop_user B on A.uid = B.uid left join store_order_cart_info C on A.`unique` = C.`unique` where A.product_id=#{productId} and A.is_del=0 order by A.create_Time DESC limit 1" })
    StoreProductReplyQueryVo getReply(final long productId);
    
    @Select({ "<script>select A.product_score as productScore,A.service_score as serviceScore,A.comment,A.merchant_reply_content as merchantReplyContent,A.merchant_reply_time as merchantReplyTime,A.pics as pictures,A.create_Time as createTime,B.nickname,B.avatar,C.cart_info as cartInfo from store_product_reply A left join eshop_user B on A.uid = B.uid left join store_order_cart_info C on A.`unique` = C.`unique` where A.product_id=#{productId} and A.is_del=0 <if test='type == 1'>and A.product_score = 5</if><if test='type == 2'>and A.product_score &lt; 5 and A.product_score &gt; 2</if><if test='type == 3'>and A.product_score &lt;= 2</if> order by A.create_Time DESC</script>" })
    List<StoreProductReplyQueryVo> selectReplyList(final Page page, @Param("productId") final long productId, @Param("type") final int type);
}
